package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.*;

/**
 * @author Artem Kalchenko
 * 
 */
public class SystemTest {

	private static Bank theBank = new Bank();
	private static BankService bs = new BankService();

	public static void main(String[] args) {
		if (args.length>0) {
			if ("-loadbank".equals(args[0])) {
				theBank = bs.loadBank(args[1]);
				System.out.println("List of clients:\n"	+ bs.getClientsListAsString(theBank));
				System.out.println(bs.getAccountsListAsString(theBank));
			}
			if ("-loadfeed".equals(args[0])) {
				theBank = bs.loadBankFromFeed(args[1]);
				System.out.println("List of clients:\n"	+ bs.getClientsListAsString(theBank));
				System.out.println(bs.getAccountsListAsString(theBank));
			}
		} else {
			runMyTests();
		}
	}

	private static void runMyTests() {
		Client clSmith = new Client("Smith", Gender.MALE);
		Client clLiskov = new Client("Liskov", Gender.FEMALE,
				new CheckingAccount(500, 100));
		Client clSmithCopy = null;

		bs.saveBank(theBank);
		
		clSmith = bs.addClient(theBank, clSmith);
		clLiskov = bs.addClient(theBank, clLiskov);

		System.out.println("List of clients:\n"
				+ bs.getClientsListAsString(theBank));
		System.out.println(bs.getAccountsListAsString(theBank));

		// add an account for Smith
		bs.addAccount(theBank, clSmith, new SavingsAccount(750));
		System.out.println(bs.getAccountsListAsString(theBank));

		theBank = bs.loadBank();
		if (theBank != null) {
			System.out.println(bs.getAccountsListAsString(theBank));
		}
	}
}
